//
//  TCIssueViewController.m
//  陶瓷
//
//  Created by 郭天龙 on 15/7/26.
//  Copyright (c) 2015年 王戈. All rights reserved.
//

#import "TCIssueViewController.h"
#import "AddMessageController.h"

@interface TCIssueViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, weak) IBOutlet UITableView *tableview;

@end

@implementation TCIssueViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
//    self.title = @"信息发布";
    [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"TCIssueCell"];
    self.tableview.tableFooterView = [UIView new];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationItem setTitle:@"信息发布"];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationItem setTitle:@""];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"TCIssueCell";
    // 1.取缓存中取
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
    
    switch (indexPath.row) {
        case 0:
        {
            cell.textLabel.text = @"招聘信息发布";
            cell.textLabel.font = [UIFont boldSystemFontOfSize:18];
            cell.detailTextLabel.text = @"精英级人才聚集地";
            cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
            UIImageView *imagev = [[UIImageView alloc] init];
            imagev.frame = CGRectMake(0, 0, 5, 60);
            imagev.backgroundColor = [UIColor colorWithString:@"#10B2CE"];
            [cell.contentView addSubview:imagev];
        }
            break;
        case 1:
        {
            cell.textLabel.text = @"商铺信息发布";
            cell.textLabel.font = [UIFont boldSystemFontOfSize:18];
            cell.detailTextLabel.text = @"仓库、店铺转让出租";
            cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
            UIImageView *imagev = [[UIImageView alloc] init];
            imagev.frame = CGRectMake(0, 0, 5, 60);
            imagev.backgroundColor = [UIColor colorWithString:@"#1033CE"];
            [cell.contentView addSubview:imagev];
        }
            break;
        case 2:
        {
            cell.textLabel.text = @"尾货信息发布";
            cell.textLabel.font = [UIFont boldSystemFontOfSize:18];
            cell.detailTextLabel.text = @"尾货甩货中心";
            cell.detailTextLabel.font = [UIFont systemFontOfSize:16];
            UIImageView *imagev = [[UIImageView alloc] init];
            imagev.frame = CGRectMake(0, 0, 5, 60);
            imagev.backgroundColor = [UIColor colorWithString:@"#8E33CE"];
            [cell.contentView addSubview:imagev];
        }
            break;
        default:
            break;
    }
    
    cell.accessoryType = UITableViewCellAccessoryNone;
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    
    NSArray *questionArray ;
    
    switch (indexPath.row) {
        case 0:
            questionArray = recruitmentQuestionArray;
            break;
        case 1:
            questionArray = rentQuestionArray;
            break;
        case 2:
            questionArray = tailGoodsQuestionArray;
            break;
        default:
            break;
    }
    AddMessageController *tcIssue = [[AddMessageController alloc] init];
    tcIssue.questionArray = questionArray;
    
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    tcIssue.title = cell.textLabel.text;
    
    [self.navigationController pushViewController:tcIssue animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
